<?php include './function.php'; ?>
<html>
    <head>

        <meta charset="UTF-8">
        <title>truong minh chung demo</title>
        <link href="he.css" rel="stylesheet" type="text/css"/>
    </head>
    <style>

    </style>
    <body>
        <?php
        $sql = 'select * from students;';
        $students = query($sql);
//        var_dump($students);
        ?>
        <div class="title">STUDENTS</div>
        <table>
            <tr>
                <td>ID</td>
                <td>Name</td>
                <th>Xóa</th>
            </tr>      
            <?php foreach ($students as $student): ?>
                <tr>
                    <td><?php echo ($student['ID']); ?></td>
                    <td><?php echo ($student['Name']); ?></td>
                    <td>
                        <form action="delete.php?ID=<?php echo $student['ID'] ?>" method="post">
                            <input type="submit" value="Delete">
                        </form>
                    </td>

                </tr>
            <?php endforeach; ?>
        </table>
        <div>Insert database</div>
        <form id="form1" name="form1" method="post" action="insert.php" onsubmit="checkForm();">
            <label>ID</label>
            <input type="text" name="basic_name1" id="textfield" />
            <label>Name</label>
            <input type="text" name="basic_name2" id="textfield" />
            <input type="submit" name="button" id="button" value="Thêm" />
        </form>
        <form id="form2" name="form2" method="post" action="update.php" onsubmit="checkForm();">
            <label>ID</label>
            <input type="text" name="basic_name1" id="textfield" />
            <label>Name</label>
            <input type="text" name="basic_name2" id="textfield" />
            <input type="submit" name="button" id="button" value="Sửa" />
        </form>
        <div>
                <h2>Tìm Kiếm</h2>
                <form name="timkiem" action="search.php" method="post">
                <input type="text" name="user" value="" size="25px" /><input type="submit" name="ok" value="Search" />
                </form>
            </div>
        <?php
        $sql1 = 'select * from staffs;';
        $staffs = query($sql1);
//        var_dump($staffs);
        ?>
        <div class="title">STAFFS</div>
        <table>
            <tr>
                <td>ID</td>
                <td>Name</td>
            </tr>      
            <?php foreach ($staffs as $staff): ?>
                <tr>
                    <td><?php echo ($staff['ID']); ?></td>
                    <td><?php echo ($staff['Name']); ?></td>

                </tr>
            <?php endforeach; ?>
        </table>
    </body>
</html>